package org.spring.blog.dao;

import org.spring.blog.pojo.Article;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface ArticleDao extends JpaRepository<Article, String>, JpaSpecificationExecutor<Article> {

    Article findOneById(String id);

    @Modifying
    int deleteAllById(String _id);

    @Modifying
    @Query(nativeQuery = true, value = "update sob_blog_system.tb_article set sob_blog_system.tb_article.state = ?2 where sob_blog_system.tb_article.id = ?1")
    int updateState(String id, String state);

    @Query(nativeQuery = true, value = "select labels from sob_blog_system.tb_article where id=?")
    String queryLabelsById(String _id);
}
